package cn.jiyun.controller;

import com.jiyun.common.pojo.product.CarOrder;
import cn.jiyun.service.CarOrderService;
import com.jiyun.Result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("carProduct/carOrder")
@Slf4j
public class CarOrderController {
    @Autowired
    private CarOrderService carOrderService;

    @GetMapping("/findAll")
    public List<CarOrder>  findAll(){
        List<CarOrder> carOrderList= carOrderService.findAll();
        return carOrderList ;
    }
    @RequestMapping("findOrderList")
    public Result findOrderList(Integer sid,String search,Integer state) {
        //根据选择的种类获取对应商品信息
        List<CarOrder> carOrderList = carOrderService.findOrderList(sid,search,state);
        return Result.ok(carOrderList);
    }
    @RequestMapping("findOrder")
    public Result findOrder(Integer sid,String search,Integer state) {
        //根据选择的种类获取对应商品信息
        List<CarOrder> carOrderList = carOrderService.findOrder(sid,search,state);
        return Result.ok(carOrderList);
    }

    @GetMapping("findSkuById/{id}")
    public CarOrder findSkuById(@PathVariable("id") Integer id) {
        CarOrder carOrder = carOrderService.findSkuById(id);
        return carOrder;
    }
}
